﻿using System;
using System.Linq;

public partial class administrator_ChangePass : System.Web.UI.Page
{
    dulieuDataContext db=new dulieuDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        var httpCookie = Request.Cookies["username"];
        if (httpCookie != null) lbltendangnhap.Text = httpCookie.Value;
    }

    protected void Unnamed1_Click(object sender, EventArgs e)
    {
        var dem = (from o in db.Users where o.Pass == txtpassold.Text select o).Count();
        if (dem!=0)
        {
            var user = (from o in db.Users where o.Pass == txtpassold.Text select o).SingleOrDefault();
            if (user != null) user.Pass = txtpassnew.Text;
            db.SubmitChanges();
            lblthongbao.Text = "Cập nhật thành công";
        }
        else
        {
            lblthongbao.Text = "Nhập sai mật khẩu cũ!";
        }
    }
}